﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Windows;

namespace Eniux.Windows.Controls.Core.Converters
{
   public class MarginConverter:IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value != null)
            {
                Thickness cr = new Thickness(8);
                double _value = (double)value;
                if (parameter != null)
                {
                    try
                    {
                        switch (parameter.ToString())
                        {
                            case "Left": cr.Left = _value; break;
                            case "Right": cr.Right = _value; break;
                            case "Bottom": cr.Bottom = _value; break;
                            case "Top": cr.Top = _value; break;
                        }

                    }
                    catch (Exception)
                    {
                        return value;
                    }
                }
                return cr;
            }
            return value;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
